﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using WeBlog.Helpers;
using WeBlog.Services;

namespace WeBlog.Models {
	public class SettingsViewModel
	{
		public SiteConfiguration Settings { get; set; }
        public bool UseSmtpAuthentication { get; set; }
		
		public SettingsViewModel()
		{
			Settings = SiteManager.CurrentConfiguration;
		}    

		public IEnumerable<SelectListItem> FeedFormats
		{
			get
			{
				var format = "RSS";
				yield return new SelectListItem { Selected = (format == "RSS"), Text = "RSS", Value = "RSS" };
				yield return new SelectListItem { Selected = (format == "Atom"), Text = "Atom", Value = "Atom" };
			}
		}

		public IEnumerable<SelectListItem> Themes
		{
			get
			{
			    var themes = FileManager.ThemeDirectory.EnumerateDirectories().Where(x => x.Name != "Admin");
				foreach (var theme in themes)
				{
					yield return new SelectListItem
					{                        
						Text = theme.Name,
						Value = theme.Name
					};
				}
			}
		}              
	}
}